package com.mall.seckill_mall.controller;

import com.mall.seckill_mall.utils.LockUtil;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class test {

//    @Autowired
//    private AmqpTemplate amqpTemplate;

    public static void main(String[] args) {
//        test t = new test();
//        t.amqpTemplate.convertAndSend("hello");
        List<String> list = new ArrayList<>();
        list.add("user1");
        list.add("user2");
        list.add("user3");
        list.add("user4");
        int i = 10;
        String key = "seckill_lock";
        LockUtil lockUtil = new LockUtil();
        while(i-- > 0) {
            for(int j = 0; j < 4; j++) {
                if(lockUtil.lock(key, list.get(j), 1L))
                    System.out.println(list.get(j) + "获得锁");
                else
                    System.out.println(list.get(j) + "没获得锁");
            }
        }
    }
}
